package com.kelaite.procurement.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.kelaite.procurement.entity.TPipelineItem;

public interface PipelineItemRepository extends
		JpaRepository<TPipelineItem, Long> {

	@Query(value = "select * from t_pipeline_lineitem where bid_id = ?1", nativeQuery = true)
	public TPipelineItem findByPipelineId(Long pipelineId);

	@Modifying
	@Query(value = "update t_pipeline_lineitem set accept = ?1, gmt_update_time = ?2, updated_by = ?3 where bid_id = ?4", nativeQuery = true)
	public int updatePipelineItemAccepted(boolean accept, Date gmtUpdateTime,
			String updatedBy, Long bidId);
	
	@Query(value = "select * from t_pipeline_lineitem where  company_id_1 =?1 order by gmt_create_time desc", nativeQuery = true)
	public List<TPipelineItem> getPipelineItemOrderByTime(Long companyId);
}
